<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*"%>

<%@ include file="/WEB-INF/jsp/common/taglib.jsp"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>ADD</title>
<link href="<s:url value="/css/standard.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/pop_up.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/maintenance.css" />" rel="stylesheet"
	type="text/css" />
<link href="<s:url value="/css/Simplemodal.css" />" rel="stylesheet"
	type="text/css" />

<script src='<c:url value="/js/common.js" />'></script>
<script src='<c:url value="/js/common_ui.js" />'></script>
<script src='<c:url value="/js/poplayer.js" />'></script>
<script src='<c:url value="/js/maint_ui.js" />'></script>
<script src='<c:url value="/js/jquery.DynamicMessage.js" />'></script>
<script src='<c:url value="/js/jquery.simplemodal-1.4.1.js" />'></script>
<script src='<c:url value="/js/jquery-1.7.2.js" />'></script>

</head>
<body>

	<hr>
	<form:form method="post" name="addForm" onsubmit="return doSubmit()">
		<table width="100%" border="0" cellspacing="0" cellpadding="0"
			class="problemDes">
			<tr>
				<td colspan="2">
					<table cellspacing="2" cellpadding="2" border="0" width="100%">
						<tr>
							<td width="150px" class="labelText">chcekInTime:</td>
							<td><input id='chcekInTime1' style="width: 50px"
								value="2013">-<input id='chcekInTime2'
								style="width: 50px" value="12">-<input id='chcekInTime3'
								style="width: 50px" value="12">
								<p style="color: red" id="chcekInMessage"></p></td>
						</tr>

						<tr>
							<td width="150px" class="labelText">chcekOutTime:</td>
							<td><input id='chcekOutTime1' style="width: 50px"
								value="2013">-<input id='chcekOutTime2'
								style="width: 50px" value="12">-<input
								id='chcekOutTime3' style="width: 50px" value="12">
								<p style="color: red" id="chcekOutMessage"></p></td>
						</tr>
						<tr>
							<td width="150px" class="labelText">createdTime:</td>
							<td><input id='createdTime1' style="width: 50px"
								value="2013">-<input id='createdTime2'
								style="width: 50px" value="10">-<input id='createdTime3'
								style="width: 50px" value="10">

								<p style="color: red" id="createMessage"></p></td>
						</tr>
						<tr>
							<td width="150px" class="labelText">employeeGrender:</td>
							<td><input onmousedown="show_child()" style="width: 160px"
								id='employeeGrender' value=""></td>
						</tr>
						<tr>
							<td width="150px" class="labelText">employeeName:</td>
							<td><input onmousedown="show_child()" style="width: 160px"
								name='employeeName' id="employeeName"
								value="${ checkInfo.employeeName }"></td>
						</tr>
						<tr>
							<td width="150px" class="labelText">employeeInfo_id:</td>
							<td><input style="width: 160px" name='employeeInfoid'
								id="employeeInfoId" value="${employeeInfoid}"
								onmousedown="show_child()" />
							<p style="color: red" id="idMessage"></p></td>

							<input type="hidden" value="" name="chcekInTime" id="chcekInTime">
							<input type="hidden" value="" name="chcekOutTime"
								id="chcekOutTime">
							<input type="hidden" value="" name="createdTime" id="createdTime">
						</tr>
					</table>
				</td>
			</tr>
			<tr>
				<td colspan="2" align="center">
					<table>
						<tr>
							<td valign="top" class="buttonRow"><input type="submit"
								class="button" name="blGo2242" value=" Submit " /></td>
							<td valign="top" class="buttonRow"><input type="button"
								value=" Back " class="button" name="blGo2242"
								onclick="toBack();" /></td>
						</tr>
					</table>
				</td>
			</tr>
		</table>

	</form:form>

	<button onclick="test()">test!!!!!</button>
	<script type="text/javascript">
		var message;

		var yearResult;
		var monResult;
		var dayResult;
		var timeResult;

		var inTime;
		var checkInResult;

		var outTime;
		var chcekOutResult;

		var created;
		var createdResult;

		var numCheckResult = true;
		var letterCheckResult = true;

		var num = [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' ];
		var letter = [ 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f',
				'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l',
				'L', 'm', 'M', 'n', 'N', 'o', 'O', 'p', 'P', 'q', 'Q', 'r',
				'R', 's', 'S', 't', 'T', 'u', 'U', 'v', 'V', 'w', 'W', 'x',
				'X', 'y', 'Y', 'z', 'Z', '+', '-', '*', '_', '.', ' ' ]
		function numCheck(obj) {
			$.each(obj, function(key, value) {
				if ($.inArray(value, num) < 0) {//存在非数字时，结果为假

					numCheckResult = false;
					return false;
				} else {

					numCheckResult = true;

				}
			})
		}
		function letterCheck(obj) {
			$.each(obj, function(key, value) {
				if ($.inArray(value, letter) < 0) {//存在非字母时，结果为假

					letterCheckResult = false;
					return false;
				} else {
					letterCheckResult = true;

				}
			})
		}
		function yearCheck(obj) {

			var year = obj.split("");
			numCheck(year);

			if (year.length == 0) {
				yearResult = false

			} else if (numCheckResult) {
				if (obj > 1989 & obj < 2100) {

					yearResult = true;
				}
			} else {

				yearResult = false

			}
			if (obj == 0) {
				yearResult = false;
			}
		}

		function monCheck(obj) {

			var mon = obj.split("");
			numCheck(mon);

			if (mon.length == 0) {
				monResult = false;
			}
			if (numCheckResult) {

				if (obj > 0 & obj < 13) {
					monResult = true;
				}
				if (obj< 0||obj >12) {
					monResult = false;
				}

			} else {
				monResult = false;

			}
			if (obj == 0) {
				monResult = false;
			}

		}

		//能整4  ON100 00能整除400 2-29
		function dayCheck(year, mon, day) {

			var yearArray = year.split("");
			var dayArray = day.split("");

			numCheck(dayArray);
			yearCheck(year);
			monCheck(mon);

			if (yearResult & monResult & numCheckResult) {

				if (day > 0 & day < 32) {

					if ((mon == 2) & (day > 0 & day < 30)) {

						if ((yearArray[yearArray.length - 1] == 0 & yearArray[yearArray.length - 2] == 0)
								& (year % 400 == 0) & (mon > 1 & mon < 3)) {

							if (day > 0 & day < 30) {
								dayResult = true;
							}
						}

						if ((yearArray[yearArray.length - 2] != 0)
								& (year % 4 == 0) & (mon > 1 & mon < 3)) {

							if (day > 0 & day < 30) {
								dayResult = true;
							}

						}

					}

					if ((mon == 4 | mon == 6 | mon == 9 | mon == 11)
							& day < 31) {

						dayResult = true;
					}
					if ((mon != 4 | mon != 6 | mon != 9 | mon != 11)
							& day < 32) {

						dayResult = true;
					}
				}

			} else {
				dayResult = false;
			}
			if (dayArray.length == 0) {

				dayResult = false;

			}
			if (((mon == 2) & day > 29)) {
				dayResult = false;
			}
			if (day > 31) {
				dayResult = false;
			}
			if (day == 0) {
				dayResult = false;
			}

		}

		function timeCheck(time1, time2, time3) {
			yearCheck(time1);
			monCheck(time2);
			dayCheck(time1, time2, time3)

			if (yearResult & monResult & dayResult) {

				timeResult = true;

				return false;
			}
			if (yearResult == false & monResult == false & dayResult == false) {

				if (tim1.split("").length == 0 & time2.split("").length == 0
						& time3.split("").length == 0) {

					message = "信息皆为空！"
					timeResult = false;
					return false;
				} else {
					message = " 年份有误, 月份有误, 日期有误"
					timeResult = false;
					return false;
				}

				timeResult = false;
				return false;
			}
			if (yearResult == false) {

				if (time1.split("").length == 0) {
					message = "年份信息不能为空！"
					timeResult = false;
					return false;
				} else {

					message = " 年份有误"
					timeResult = false;
					return false;
				}

				timeResult = false;
				return false;
			}
			if (monResult == false) {

				if (time2.split("").length == 0) {
					message = "月份信息不能为空！"
					timeResult = false;
					return false;
				} else {
					message = " 月份有误"
					timeResult = false;

				}

			}
			if (dayResult == false) {
				alert("time tudao !")
				if (time3.split("").length == 0) {
					message = "日期信息不能为空！"
					timeResult = false;
					return false;
				}
				message = "日期信息有误"
				timeResult = false;
				return false;
			}
			if (yearResult.split("").length == 0
					|| monResult.split("").length == 0
					|| dayResult.split("").length == 0) {
				alert("funtion:miss")
				timeResult = false;
				return false;
			}

		}

		function chcekInTime() {
			var chcekInTime1 = $("#chcekInTime1").val();
			var chcekInTime2 = $("#chcekInTime2").val();
			var chcekInTime3 = $("#chcekInTime3").val();
			timeCheck(chcekInTime1, chcekInTime2, chcekInTime3)

			if (timeResult) {
				inTime = chcekInTime1 + "-" + chcekInTime2 + "-" + chcekInTime3
				checkInResult = true;
				return false
			} else {
				$("#chcekInMessage").text("ChcekInMessage: " + message);
				return false;
			}

		}

		function chcekOutTime() {
			var chcekOutTime1 = $("#chcekOutTime1").val();
			var chcekOutTime2 = $("#chcekOutTime2").val();
			var chcekOutTime3 = $("#chcekOutTime3").val();
			timeCheck(chcekOutTime1, chcekOutTime2, chcekOutTime3)
			if (timeResult) {
				outTime = chcekOutTime1 + "-" + chcekOutTime2 + "-"
						+ chcekOutTime3
				chcekOutResult = true;
				return false;
			} else {

				$("#chcekOutMessage").text("ChcekOutMessage: " + message);
				return false;
			}

		}

		function createdTime() {
			var createdTime1 = $("#createdTime1").val();
			var createdTime2 = $("#createdTime2").val();
			var createdTime3 = $("#createdTime3").val();
			timeCheck(createdTime1, createdTime2, createdTime3)

			if (timeResult) {
				created = createdTime1 + "-" + createdTime2 + "-"
						+ createdTime3;
				createdResult = true;
				return false;

			} else {
				$("#createMessage").text("CreateMessage: " + message);
				return false;
			}

		}

		function doSubmit() {

			chcekInTime();
			chcekOutTime()
			createdTime()
			var id = $("#employeeInfoId").val().split("").length;
			if (checkInResult & chcekOutResult & createdResult & id > 0) {
				$("#chcekInTime").val(inTime);
				$("#chcekOutTime").val(outTime);
				$("#createdTime").val(created);

				addForm.action = "<c:url value='/checkinfo/add'/>";
				return true;
			} else {
				
				return false;
			}

		}
		function toBack() {
			self.location = "<c:url value='/checkinfo/page'/>";
		}
		function show_child() {
			window
					.open(
							"<c:url value='/employeeinfo/childpage'/>",
							"child",
							"height=500,width=1000,top=50,left=50,status=yes,toolbar=yes,menubar=yes,location=yes");

		}

		function test() {
			alert(createdTime());
		}
	</script>
</body>
</html>